package com.sagframe.sagacity.sqltoy.plus.chain.update;

import com.sagframe.sagacity.sqltoy.plus.chain.ChainDao;
import com.sagframe.sagacity.sqltoy.plus.chain.ChainUpdate;
import com.sagframe.sagacity.sqltoy.plus.conditions.AbstractUpdateWrapper;
import com.sagframe.sagacity.sqltoy.plus.conditions.segments.MergeSegments;

import java.util.concurrent.atomic.AtomicInteger;

public abstract class AbstractChainUpdateQueryWrapper<T, R, Children extends AbstractChainUpdateQueryWrapper<T, R, Children>> extends AbstractUpdateWrapper<T, R, Children> implements ChainUpdate {

    protected ChainDao chainDao;

    protected AbstractChainUpdateQueryWrapper(MergeSegments expression, AtomicInteger paramNameSeq, Class<T> entityClass) {
        super(expression, paramNameSeq, entityClass);
    }

    public AbstractChainUpdateQueryWrapper(MergeSegments expression, Class<T> entityClass, ChainDao chainDao) {
        super(expression, entityClass);
        typedThis.chainDao = chainDao;
    }

    @Override
    public long update() {
        return chainDao.getDao().update(typedThis);
    }
}
